//
//  EnumDefinition.cpp
//  Chart
//
//  Created by Javen Wang on 12/22/14.
//
//

#include "EnumDefinition.h"

namespace ytx {

namespace IndexType {
    //ADDIndex:
    std::string ConvertIndexTypeToString(const IndexType indexType) {
        switch(indexType){
            case QK:
              return "QK";
            case QKT:
                return "QKT";
            case TJ:
              return "TJ";
            case GameMatrix:
                return "BYJZ";
            case HJJT:
                return "HJJT";
            case MA:
              return  "MA";
            case BOLLIN:
              return  "BOLLIN";
            case EconomicCalendar:
              return  "EconomicCalendar";
            case VOLUME:
              return  "VOLUME";
            case Tuov:
                return  "Tuov";//成交额
            case MACD:
              return  "MACD";
            case KDJ:
              return  "KDJ";
            case RSI:
              return  "RSI";
            case BIAS:
              return  "BIAS";
            case CCI:
                return  "CCI";             
            default:
              return "EMPTY";
        }
    };
    //ADDIndex:
    IndexType ConvertIndexTypeFromString(const std::string indexType)
    {
        if ( indexType == "QK" || indexType == "QKX"){
            return QK;
        }
        if ( indexType == "QKT"){
            return QKT;
        }
        if ( indexType == "BYJZ" || indexType == "GM"){
            return GameMatrix;
        }
        if ( indexType == "HJJT"){
            return HJJT;
        }
        if ( indexType == "HJJTJC"){
            return HJJTJC;
        }
        if ( indexType == "HJJTGJ"){
            return HJJTGJ;
        }
        if ( indexType == "HJJTZX"){
            return HJJTZX;
        }
        if ( indexType == "TJ" || indexType == "TJX" || indexType == "60m" || indexType == "180m" || indexType == "240m"){//黄金阶梯60m 存在潜在bug
            return TJ;
        }
        if ( indexType == "MA"){
            return  MA;
        }
        if ( indexType == "BOLLIN"){
            return  BOLLIN;
        }
        if ( indexType ==  "EconomicCalendar" ){
            return  EconomicCalendar;
        }
        if ( indexType == "VOLUME"){
            return  VOLUME;
        }
        if ( indexType == "Tuov"){//成交额
            return  Tuov;
        }
        if ( indexType == "MACD"){
            return  MACD;
        }
        if ( indexType == "KDJ"){
            return  KDJ;
        }
        if ( indexType == "RSI"){
            return  RSI;
        }
        if ( indexType == "BIAS"){
            return  BIAS;
        }
        if ( indexType == "CCI"){
            return  CCI;
        }
        if ( indexType == "LSP"){
            return  LSP;
        }
        
        return EMPTY;
    }
}

namespace LineType {

std::string convertLineTypeToString(const LineType ltype) {
    switch(ltype){
        case LAVG:
            return "AVG";
//        case LAVG2:
//            return "AVG2";
//        case LAVG5:
//            return "AVG5";
        case L5m:
            return "5m";
        case L15m:
            return "15m";
        case L30m:
            return "30m";
        case L60m:
            return "60m";
//        case L120m:
//            return "120m";
//        case L180m:
//            return "180m";
//        case L240m:
//            return "240m";
        case L1d:
            return "1d";
        case L1w:
            return "1w";
//        case L1M:
//            return "1M";
        default:
            return "EMPTY";
    }
}

LineType convertLineTypeFromString(const std::string ltype) {
    std::string type = "L" + ltype;
    if (type == "LAVG"){
        return LAVG;
    }
//    else if (type == "LAVG2"){
//        return LAVG2;
//    }
//    else if (type == "LAVG5"){
//        return LAVG5;
//    }
//    else if (type == "L1m"){
//        return L1m;
//    }
    else if (type == "L5m"){
        return L5m;
    }
    else if (type == "L15m"){
        return L15m;
    }
    else if (type == "L30m"){
        return L30m;
    }
    else if (type == "L60m"){
        return L60m;
    }
//    else if (type == "L120m"){
//        return L120m;
//    }
//    else if (type == "L180m"){
//        return L180m;
//    }
//    else if (type == "L240m"){
//        return L240m;
//    }
    else if (type == "L1d"){
        return L1d;
    }
    else if (type == "L1w"){
        return L1w;
    }
//    else if (type == "L1M"){
//        return L1M;
//    }
    return EMPTY;
}
    
int getRequestParamOfQuotationTypeMinute(const LineType ltype)
{
    switch(ltype){
//        case L1m:
//            return 1;
        case L5m:
            return 5;
        case L15m:
            return 15;
        case L30m:
            return 30;
        case L60m:
            return 60;
//        case L120m:
//            return 120;
//        case L180m:
//            return 180;
//        case L240m:
//            return 240;
        case L1d:
            return 1440;
        case L1w:
            return 1440 * 7;
//        case L1M:
//            return 1440 * 30;
        default:
            return 0;
    }
}
    
int getRequestParamOfQuotationType(const LineType ltype)
{
    switch(ltype){
        case LAVG:
//        case L1m:
            return 1;
        case L5m:
            return 5;
        case L15m:
            return 15;
        case L30m:
            return 30;
        case L60m:
            return 60;
//        case L120m:
//            return 120;
//        case L180m:
//            return 180;
//        case L240m:
//            return 240;
        case L1d:
            return 1440;
        case L1w:
            return 1440 * 7;
//        case L1M:
//            return 1440 * 30;
    default:
        return 0;
    }
        
}

bool isMinuteLine(const LineType ltype){
    switch(ltype){
        case L1d:
        case L1w:
//        case L1M:
        case EMPTY:
        case LAVG:
//        case LAVG2:
//        case LAVG5:
            return false;
        default:
            return true;
    }

}
    
bool isMinutekLine(const LineType ltype) {
    switch(ltype){
        case LAVG:
        case L1d:
        case L1w:
        case EMPTY:
            return false;
        default:
            return true;
    }
}

bool isKLine(const LineType ltype){
    return ltype != LAVG /*&& ltype != LAVG2 && ltype != LAVG5*/ && ltype != EMPTY;
}

}
}
